
#ifndef RTCONNECTORWRAPPER_H
#define RTCONNECTORWRAPPER_H

#if defined (RT_WIN32) || defined (RT_PORT_CLIENT) //Be not server.
//  #define RT_SUPPORT_OPENSSL 1
#endif // RT_WIN32

#include "RtConnectionInterface.h"
#include "RtReactorInterface.h"
#include "RtReferenceControl.h"

class /*RT_API_EXPORT*/ CRtConnectorWrapper 
	: public IRtConnector
	, public IRtTimerHandler
	, public CRtReferenceControlSingleThread
{
public:
	CRtConnectorWrapper();
	virtual ~CRtConnectorWrapper();

	// interface IRtReferenceControl
	virtual DWORD AddReference();
	virtual DWORD ReleaseReference();

	RtResult Init(CRtConnectionManager::CType aType);

	int OnConnectIndication(
		RtResult aReason, 
		IRtTransport *aTrpt,
		IRtConnectorInternal *aId);

	// interface IRtAcceptorConnectorId
	virtual BOOL IsConnector();

	// interface IRtConnector
	virtual void AsycConnect(
		IRtAcceptorConnectorSink* aSink,
		const CRtInetAddr& aAddrPeer, 
		CRtTimeValue* aTimeout = NULL,
		CRtInetAddr *aAddrLocal = NULL);

	virtual void CancelConnect();

protected:
	// interface IRtTimerHandler
	virtual void OnTimeout(const CRtTimeValue &aCurTime, LPVOID aArg);

	void Close_i();

private:
	IRtReactor *m_pReactor;
	IRtAcceptorConnectorSink *m_pSink;
	IRtConnectorInternal *m_pConnector;
	BOOL m_bClosed;
};

#endif // !RTCONNECTORWRAPPER_H
